class Button extends egret.Sprite{
    lbl:egret.TextField;
    gap:number = 8;
    private _label:string;
    public constructor(labelText:string=""){
        super();
        this.lbl = new egret.TextField();
        this.lbl.textColor = 0x000000;
        this.addChild(this.lbl);
        this.lbl.x = this.gap/2;
        this.lbl.y = this.gap/2;
        this.touchEnabled = true;
        this.label = labelText;
    }

    public set label(value:string)
    {
        this._label = value;
        this.lbl.text = this._label;
        this.draw();
    }
    public get label():string
    {
        return this._label;
    }
    private draw(){
        this.graphics.clear();
        this.graphics.beginFill(0xcccccc);        
        this.graphics.drawRect(0,0,this.lbl.textWidth+this.gap,this.lbl.textHeight+this.gap);
        this.graphics.endFill();

    }
}